package com.personalsystem.function.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Component;

import com.personalsystem.function.bean.Functions;
import com.personalsystem.function.dao.FunctionDao;
import com.personalsystem.tool.hibernate.BaseDaoImpl;
import com.personalsystem.tool.hibernate.Finder;
import com.personalsystem.tool.page.Page;


@Component("functionDao")
public class FunctionDaoImpl extends BaseDaoImpl<Functions> implements FunctionDao{

	public List<Functions> getList() {
		// TODO Auto-generated method stub
		return find("from Functions where status!=-10", null);
	}
	
	@Override
	public Functions deleteById(Serializable id) {
		// TODO Auto-generated method stub
		Functions functions=get(id);
		functions.setStatus(-10);
		functions=(Functions)update(functions);
		return functions;
	}

	public Page getPage(int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		Finder finder=Finder.create("from Functions where status!=-10");
		return find(finder, pageNo, pageSize);
	}

	public Page getPageByPid(int pageNo, int pageSize, long pid) {
		// TODO Auto-generated method stub
		Finder finder=Finder.create("from Functions where status!=-10 and pid=:pid");
		finder.setParam("pid", pid);
		return find(finder, pageNo, pageSize);
	}

	

	

}
